<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use think\Db;
class Timedtask extends Frontend
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';
    public function index()
    {    
        date_default_timezone_set('Asia/Shanghai');
        // date_default_timezone_set('PRC');
        //$createtime= time()-60;
        $sheetContent=Db::connect('db_s')->query('select * from XAUT_MON.dbo.XAUT_CEDType');
         $data =[];
         $createtime= time();
         for($i=0 ; $i<count($sheetContent); $i++){ 
            $CEDTypeID=$sheetContent[$i]['CEDTypeID'];
            $chonfu = db("wbdata")->where('CEDTypeID',$CEDTypeID)->find(); 
            if($sheetContent[$i]['CEDTypeID'] != $chonfu['CEDTypeID']){
                $data[]=[ 'CEDTypeID' => $sheetContent[$i]['CEDTypeID'], 'CEDTypeName'=>$sheetContent[$i]['CEDTypeName'],'createtime'=> $createtime]; 
            }
        } 
        $db = Db::name('wbdata'); 
        $res = $db->insertAll($data);
    }

}
